﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


class PrintsAllThePermutations
{
    public static void PrintSubSet(int[] nums)
    {
        List<int> List = new List<int>();
        int[] elements = new int[nums.Length];
        int copy = 0;
        int counter = 1;
        int count = 0;
        int size = nums.Length * 2;

        for (int i = 0; i < nums.Length; i++)
        {
            for (int j = 0; j < nums.Length; j++)
            {
                List.Add(nums[j]);
                if (j == nums.Length - 1)
                {
                    for (int a = 0; a < nums.Length; a++)
                    {
                        elements[a] = nums[nums.Length - counter];
                        counter++;
                        List.Add(elements[a]);
                    }
                    Array.Copy(elements, nums, nums.Length);
                }
               
            }
            copy = nums[nums.Length - 1];
            nums[nums.Length - 1] = nums[nums.Length - 2];
            nums[nums.Length - 2] = copy;
            counter = 1;
        }

        nums = new int[size * elements.Length];
        Console.Write("{");
        for (int k = 0; k < size * elements.Length; k++)
        {
            nums[k] = List[k];
            count++;
            Console.Write(nums[k] + ",");
            if (count % elements.Length == 0 && count != 0 && k != size * elements.Length - 1)
            {
                Console.Write("}, {");
            }
            
        }
        Console.Write("}");
        Console.WriteLine();
    }

    static void Main()
    {
        int count = int.Parse(Console.ReadLine());
        int[] nums = new int[count];
        
        for (int index = 0; index < count; index++)
        {
            nums[index] = index + 1;
        }
       
        int size = nums.Length * 2;
        int length = nums.Length;
        int[] values = new int[size * length];
        PrintSubSet(nums);
    }
}